package main

import (
	"fmt"
	"math/rand"
)

/*
	使用go编写随机点名系统
	切片类型存放全班同学的名字：["史伟名","易鸽玲"]
	按任意键，不限次数随机抽取切片中的某一个同学名字回答问题
			 抽取到的同学就从切片中删除
	按q退出，或者切片里面所有的同学都已近被抽到
"张三", "李四", "王五", "赵六", "钱七"
"张三", "李四", "赵六", "钱七"
*/

func main() {
	name := []string{"张三", "李四", "王五", "赵六", "钱七"}
	username := ""
	for {
		if len(name) == 0{
			fmt.Printf("抽完了，系统将自动退出")
			break
		}
		fmt.Printf("按任意键抽取(按q退出)\n")
		fmt.Scanf("%s",&username)
		if username == "q" {
			break
		}
		num := rand.Intn(len(name))
		fmt.Printf("%s\n",name[num] )
		// 删除
		name = append(name[:num],name[num+1:]...)
	}
}
